package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemAlbumBo;
import com.cw.jeeyt.dao.model.system.SystemAlbumDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 相册管理转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemAlbumConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemAlbumBo do2Bo(SystemAlbumDo model) {
        if (model == null) {
            return null;
        }
        SystemAlbumBo bo = new SystemAlbumBo();
        bo.setId(model.getId());
        bo.setAlbumCode(model.getAlbumCode());
        bo.setAlbumName(model.getAlbumName());
        bo.setAlbumType(model.getAlbumType());
        bo.setAlbumComment(model.getAlbumComment());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemAlbumDo bo2Do(SystemAlbumBo bo) {
        if (bo == null) {
            return null;
        }
        SystemAlbumDo model = new SystemAlbumDo();
        model.setId(bo.getId());
        model.setAlbumCode(bo.getAlbumCode());
        model.setAlbumName(bo.getAlbumName());
        model.setAlbumType(bo.getAlbumType());
        model.setAlbumComment(bo.getAlbumComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemAlbumBo> doList2BoList(List<SystemAlbumDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemAlbumConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemAlbumDo> boList2DoList(List<SystemAlbumBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemAlbumConverter::bo2Do));
    }
}